﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BlueQuiz.Models;

namespace BlueQuiz.Controllers
{
    public class QuestionController : Controller
    {
        //
        // GET: /Question/
        BluequizEntities db = new BluequizEntities();

        public ActionResult Index()
        {
            var questions = db.bq_Question.ToList();

            return View(questions);
        }

        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create(bq_Question question)
        {
            if (ModelState.IsValid)
            {
                db.bq_Question_Create(
                    Guid.NewGuid(),
                    question.Content,
                    1);

                return RedirectToAction("Index");
            }
            else
            {
                return View(question);
            }
        }
    }
}
